package com.bc.bccore.util;

/**
 * @Name MyX509TrustManager
 * @Description TODO
 * @Author douhaichao
 * @Date 2019/5/17 17:45
 * @Version 1.0
 **/

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import javax.net.ssl.X509TrustManager;

public class MyX509TrustManager implements X509TrustManager  {
    public void checkClientTrusted(X509Certificate[] chain, String authType)
            throws CertificateException {
    }

    public void checkServerTrusted(X509Certificate[] chain, String authType)
            throws CertificateException {
    }

    public X509Certificate[] getAcceptedIssuers() {
        return null;
    }

    public boolean verify(String hostname, SSLSession session) {
        // 直接返回true:默认所有https请求都是安全的
        return true;
    }

    public class TrustAnyHostnameVerifier implements HostnameVerifier {
        public boolean verify(String hostname, SSLSession session) {
            // 直接返回true:默认所有https请求都是安全的
            return true;
        }
    }

}